package cn.dida.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.dida.model.HttpResponseBodyWrapper;
import cn.dida.model.RgnRegion;
import cn.dida.service.AreaService;
/**
 * <p>区域信息  </p>
 * @author lisha
 * @date 2016-11-15 10:59
 * */
@Controller
public class AreaController extends BaseController {
	
	@Autowired
	private AreaService areaService;
	
	/**
	 * 根据父节点id获取区域信息
	 * */
	@ResponseBody
    @GetMapping(value = "/region", produces = MediaType.APPLICATION_JSON_VALUE)
    public HttpResponseBodyWrapper getBrand(HttpServletRequest request, Integer parentId) throws Exception {
        Map<String, Object> model = new HashMap<String, Object>();
        List<RgnRegion> regionList = areaService.regionList(parentId);
        model.put("regionList", regionList);
        return new HttpResponseBodyWrapper(regionList);
    }
}
